package com.zb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.ZjSmsReceiveRoleEmp;
import com.zb.mapper.ZjSmsReceiveRoleEmpMapper;
import com.zb.service.ZjSmsReceiveRoleEmpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 商家短信接收角色指定人员表 服务实现类
 * </p>
 *
 * @author WEN
 * @since 2024-05-22
 */
@Service
public class ZjSmsReceiveRoleEmpServiceImpl extends ServiceImpl<ZjSmsReceiveRoleEmpMapper, ZjSmsReceiveRoleEmp> implements ZjSmsReceiveRoleEmpService {
    @Resource
    private ZjSmsReceiveRoleEmpMapper smsReceiveRoleEmpMapper;

    // 根据短信模板ID删除指定人员
    @Override
    public void deleteBySmsTemplateId(Long smsTemplateId) {
        QueryWrapper<ZjSmsReceiveRoleEmp> wrapper = new QueryWrapper<>();
        wrapper.eq("sms_template_id", smsTemplateId);
        this.remove(wrapper);
    }

    // 根据短信模板ID获取指定人员
    @Override
    public List<ZjSmsReceiveRoleEmp> getBySmsTemplateId(Long smsTemplateId) {
        QueryWrapper<ZjSmsReceiveRoleEmp> wrapper = new QueryWrapper<>();
        wrapper.select("id", "sms_template_id", "sms_receive_role_id", "emp_id")
                .eq("sms_template_id", smsTemplateId);
        return this.list(wrapper);
    }

    // 根据短信模板ID获取指定人员的手机号
    @Override
    public List<String> getEmpPhoneBySmsTemplateId(Long smsTemplateId) {
        return smsReceiveRoleEmpMapper.getEmpPhoneBySmsTemplateId(smsTemplateId);
    }
}
